<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="generator" content="ScreenSteps http://www.screensteps.com/" />
	<title>Getting Started</title>
	<link href="../css/modern.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8" />
	<link href="../css/prettyPhoto.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8" />
	<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
  <script type="text/javascript" charset="utf-8">
		$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({
			  show_title: false
			});
		});
  </script>
</head>

<body class="trebuchet">
	<div id="wrapper">		
		<div id="LessonContent">
			<div class="LessonHeader">
			  <p><a href="../nKnight.html">Back to Table of Contents</a></p>
				<h1 class="LessonTitle">Getting Started</h1>
			</div>
			
			
				<div id="step_1" class="lessonStep top">
	    
		 <p>In the downloaded .zip file you will find the following .dll files,</p>
<ol>
<li>nKnight.dll</li>
<li>nKnightD.dll</li>
<li>nKnightControls.dll</li>
</ol><p>You can add dlls 1 and 2 from &ldquo;Add Reference&rdquo; in visual studio. And if you want to use nKnight controls then from toolbox you have to choose the 3rd dll.<br />
Now you have to tell nKnight which database you are using by sending an open connection to the nKnight datalayer. The database holds the matrix of the roles and their authorizations. The first thing that you need to have is a MySQL installation and access to the database. Open up a valid connection with the following piece of code (change data values of the following fields, i. e., SERVER, PORT, DATABASE, USER and PASSWORD):<br />
<font color="#0000FF">string</font> conStr = <font color="#A31515">"DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;PORT=3306;DATABASE=RBAC;USER=root;PASSWORD=xxx;OPTION=3"</font>; <font color="#00B050">//Connection string to RBAC database.</font><br />
<font color="#C00000">IDbConnection con = (IDbConnection)new OdbcConnection(conStr);</font><br />
<font color="#C00000">con.Open();</font> <font color="#00B050">//Open the connection</font><br />
Now you can proceed for initializing the nKnight datalayer by sending this kind of an open connection. <br />
<font color="#C00000">DataLayer dbl = new DataLayer(con, DataLayer.DatabaseType.MySql);</font> <font color="#00B050">//Initialize datalayer by sending open connection and database type.</font><br />
<font color="#00B050">///con here is a variable, change it with an actual connection string. User won't be able to to understand what con is then. Or else you can declare con in the previous line.</font><br />
<font color="#00B050">Remember: this release only accepts Mysql database. </font></p>


<p>After this you will need to activate nKnight security layer by sending this datalayer object and user name and password. Confused!!! Ok don&rsquo;t worry I will show you how,<br />
<font color="#C00000">bool d = SecurityPrincipal.InitSecuritySystem(dbl, "Admin", "Admin"); </font><font color="#00B050">//Initializing security system by sending datalayer object and username and password. If any thing goes wrong then it will throw an error</font></p>


<p>Once you&rsquo;ve set up security layer then just drag and drop nKnight controls from toolbox into your forms.  System will automatically generate one unique id for every control and you can access it from &ldquo;GroupUniqueId&rdquo; property. </p>
	</div>
	<div class="clear"></div>

		</div>
		<div id="LessonPageNav">
		  <p></p>
		  <ul>
		    <li id="LessonPagePrevious"><a href="Introduction_to_nKnight.html">Previous Page: Introduction to nKnight</a> &nbsp;</li>
		    <li id="LessonPageCount">Page <strong>2</strong> of <strong>5</strong></li>
		    <li id="LessonPageNext"><a href="Adding_and_working_with_nKnightControls.html">Next Page: Adding and working with nKnightControls</a> &nbsp;</li>
		    
		  </ul>
		</div>
	</div>	
</body>
</html>